home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Information
/
CSMP Digest
/
volume 3
/
csmp-digest-v3-121
< prev
next >
Wrap
Text File
|
1995-12-31
|
44KB
|
1,227 lines
C.S.M.P. Digest Sun, 12 Nov 95 Volume 3 : Issue 121
Today's Topics:
32K code segments?
Apple Guide 2.0
Boot Blocks Again
Building an FSSpec
Drag And Drop for TextEdit
Getting file info from file reference number
PPC App + 68K module & callbacks (how?)
Q: Time Manager vs TickCount for Animation?
Q: system heap expansion at init time
[Q] To form this FSSpec...
The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
(pottier@clipper.ens.fr).
The digest is a collection of article threads from the internet
newsgroups comp.sys.mac.programmer.help, csmp.tools, csmp.misc and
csmp.games. It is designed for people who read news semi-regularly and
want an archive of the discussions. If you don't know what a
newsgroup is, you probably don't have access to it. Ask your systems
administrator(s) for details. If you don't have access to news, you
may still be able to post messages to the group by using a mail server
like anon.penet.fi (mail help@anon.penet.fi for more information).
Each issue of the digest contains one or more sets of articles (called
threads), with each set corresponding to a 'discussion' of a particular
subject. The articles are not edited; all articles included in this digest
are in their original posted form (as received by our news server at
nef.ens.fr). Article threads are not added to the digest until the last
article added to the thread is at least two weeks old (this is to ensure that
the thread is dead before adding it to the digest). Article threads that
consist of only one message are generally not included in the digest.
The digest is officially distributed by two means, by email and ftp.
If you want to receive the digest by mail, send email to listserv@ens.fr
with no subject and one of the following commands as body:
help Sends you a summary of commands
subscribe csmp-digest Your Name Adds you to the mailing list
signoff csmp-digest Removes you from the list
Once you have subscribed, you will automatically receive each new
issue as it is created.
The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
Questions related to the ftp site should be directed to
scott.silver@dartmouth.edu.
-------------------------------------------------------
>From Johnny C Lam <jlbg+@andrew.cmu.edu>
Subject: 32K code segments?
Date: Sun, 22 Oct 1995 03:52:53 -0400
Organization: Senior, Mathematics, Carnegie Mellon, Pittsburgh, PA
I have Symantec C++, and I was writing some threading routines on paper
then trying to compile them. I ran into the "code too large" error,
which meant my code segment compiled to be over 32K, because I declared
a rather large global array.
Is there some reason why segments have to be 32K and under? I thought I
read somewhere that everything compiled on a Mac has PC-relative code.
So is it because you can't access anything more than 32K off the PC
register? PC counter with displacement looks like xx(PC), where xx is a
16-bit number?
What about program counter with index? Can I use that to access stuff
that's more than 32K from the PC? Meaning, can I reference xx(PC, D0.L)
and get an address that's more than 32K from the PC?
Is that how UNIXs for the Mac do it? I know UNIX code is compiled into
a text, data, and blank static storage regions, so all of the variables
is stored in the data and bss regions. Do those UNIXs put the offset of
the the data region from the base address into a register and use the PC
with index addressing scheme to reference the variables, so that I can
declare more than 32K of globals in my UNIX programs?
Sorry that I have so many questions.
One more question: if I am working on designing an OS for the Mac, is
there another place I should be posting my questions? I am working on a
UNIX-like OS and I have a lot of questions about operating systems in
general.
--Johnny
+++++++++++++++++++++++++++
>From macjack@ids.net
Date: Mon, 23 Oct 95 15:00:26 +500
Organization: IDS World Network Internet Access Service, (800)IDS-1680
tulip@tiac.net (Ed Anson) writes:
>> Is there some reason why segments have to be 32K and under? I thought I
>> read somewhere that everything compiled on a Mac has PC-relative code.
>> So is it because you can't access anything more than 32K off the PC
>> register? PC counter with displacement looks like xx(PC), where xx is a
>> 16-bit number?
>
>Bingo! That is exactly why code segments are limited to 32K.
Wait a second here.. Can't one have segments larger than 32k by taking
advantage of 32 bit addressing?
--
Louis Deaett
<macjack@ids.net>
+++++++++++++++++++++++++++
>From tulip@tiac.net (Ed Anson)
Date: Sun, 22 Oct 1995 16:51:50 -0400
Organization: Tulip Software
In article <0kWTVJe00iVCM0j0dd@andrew.cmu.edu>, Johnny C Lam
<jlbg+@andrew.cmu.edu> wrote:
> I have Symantec C++, and I was writing some threading routines on paper
> then trying to compile them. I ran into the "code too large" error,
> which meant my code segment compiled to be over 32K, because I declared
> a rather large global array.
Global arrays do not affect code segment size. They affect the global
size, which is also nominally restricted to 32K.
BTW: Large global arrays are typically not a good idea. It is better to
allocate large arrays from the heap, using NewPtr(). If you really want it
to be global (or a static member in C++) you can declare it thus:
long* myArray = NewPtr(nElements*sizeof(long));
It is then globally available, and can be used syntactically just like an array.
> Is there some reason why segments have to be 32K and under? I thought I
> read somewhere that everything compiled on a Mac has PC-relative code.
> So is it because you can't access anything more than 32K off the PC
> register? PC counter with displacement looks like xx(PC), where xx is a
> 16-bit number?
Bingo! That is exactly why code segments are limited to 32K.
However, the system supports Far Model for both code and data. Far model
code uses absolute addressing, so it is less efficient. But it permits
essentially unlimited code size. Presumably, your compiler/linker provides
that option, since most current development systems do.
- --------------------
Ed Anson MediaTree: multimedia outline editor & catalog
Tulip Software
Andover, MA 01810 For details, check out my WWW page:
U.S.A. <http://www.tiac.net/users/tulip/home.html>
+++++++++++++++++++++++++++
>From eric.kidd@dartmouth.edu (Eric M. Kidd)
Date: 25 Oct 1995 14:49:27 GMT
Organization: Dartmouth College
In article <0kWTVJe00iVCM0j0dd@andrew.cmu.edu>, Johnny C Lam
<jlbg+@andrew.cmu.edu> wrote:
> I have Symantec C++, and I was writing some threading routines on paper
> then trying to compile them. I ran into the "code too large" error,
> which meant my code segment compiled to be over 32K, because I declared
> a rather large global array.
Depending on you version of Symantec C++, you need to turn on "far data"
(or "far code", depending on your problem), as best I remember. It has
been quite a while. =)
Metrowerks C/C++ does a good job of handling lots of data--I've got an app
with about 80k of global data (PowerPlant, ANSI C, iostreams, debug junk)
and it works just fine.
Just be sure not to allocate enormous arrays on the stack. You can easily
cause overflow under the MacOS.
Cheers,
Eric
........................................................................
Eric Kidd (eric.kidd@dartmouth.edu) http://coos.dartmouth.edu/~emk/
"Computers are useless. They can only give you answers." -Pablo Picasso
+++++++++++++++++++++++++++
>From rac@intrigue.com (Robert Coie)
Date: Wed, 25 Oct 1995 18:23:49 -0800
Organization: Intrigue Corporation
In article <tulip-2210951651510001@tulip.tiac.net>, tulip@tiac.net (Ed
Anson) wrote:
: In article <0kWTVJe00iVCM0j0dd@andrew.cmu.edu>, Johnny C Lam
: <jlbg+@andrew.cmu.edu> wrote:
: > Is there some reason why segments have to be 32K and under? I thought I
: > read somewhere that everything compiled on a Mac has PC-relative code.
: > So is it because you can't access anything more than 32K off the PC
: > register? PC counter with displacement looks like xx(PC), where xx is a
: > 16-bit number?
:
: Bingo! That is exactly why code segments are limited to 32K.
I was under the impression that the 32K limit was imposed by the original
Resource Manager.
Robert Coie rac@intrigue.com
Implementor, Intrigue Corporation AppleLink: INTRIGUE
+++++++++++++++++++++++++++
>From siegel@tiac.net (Rich Siegel)
Date: Fri, 27 Oct 1995 00:08:29 -0400
Organization: Bare Bones Software, Inc.
In article <rac-2510951823490001@intrigue.intrigue.com>, rac@intrigue.com
(Robert Coie) wrote:
> In article <tulip-2210951651510001@tulip.tiac.net>, tulip@tiac.net (Ed
> Anson) wrote:
>
> : In article <0kWTVJe00iVCM0j0dd@andrew.cmu.edu>, Johnny C Lam
> : <jlbg+@andrew.cmu.edu> wrote:
> : > Is there some reason why segments have to be 32K and under? I thought I
> : > read somewhere that everything compiled on a Mac has PC-relative code.
> : > So is it because you can't access anything more than 32K off the PC
> : > register? PC counter with displacement looks like xx(PC), where xx is a
> : > 16-bit number?
> :
> : Bingo! That is exactly why code segments are limited to 32K.
>
> I was under the impression that the 32K limit was imposed by the original
> Resource Manager.
Historically, there are several 32K-bounded limits:
1) The old Resource Manager had a bug in which resources whose sizes fell
in between even multiples of 32K would cause problems (0-32K was fine,
32-64K was not, 64-96K was fine, and so on). This bug has long since been
fixed.
2) The original 68000 (used in the original Mac) limited
address-register-relative displacements to 16 bits. Since the "classic"
Mac runtime model placed global data in negative displacements relative to
A5, and stored the jump table (used for cross-segment calls) in positive
displacements relative to A5, this meant that the size of the global data
space was limited to 32K, and the size of the jump table was limited to
32K.
3) The aforementioned jump table for cross-segment calls uses a signed
16-bit value as the segment-relative offset. This means that no entry
point called through the jump table can be more than 32K from the start of
the code segment.
(Some linkers may provide alternatives to this as part of their 'far code'
linkage model, but I haven't paid close attention here.)
Most of these limitations can be worked around by throwing the appropriate
switches in your compiler and/or linker, though at some penalty in code
size (and an extra bit of overhead whenever a segment load occurs). Of
course, with the advent of the Code Fragment Manager (first seen on the
Power Macs, and shortly available for 68K machines), these 32K limits are
largely relegated to the dustbin of history...
R.
---------------------------
>From Alex Rosen <alex@procd.com>
Subject: Apple Guide 2.0
Date: 23 Oct 1995 18:18:30 GMT
Organization: Pro CD, Inc.
Apple Guide 2.0 is out, available at
ftp://ftp.info.apple.com/Apple.Support.Area/Developer_Services/System_S
ftware_Extensions/Apple_Guide_Authoring_Kit/
I just installed this under a brand-new 7.1.2 install on a 7100/66, and
after just a few minutes of playing it seems a lot different than under
7.5. Does anyone else have similar problems? Will there be a list of
incompatibilities or lack of functionality on pre-7.5 systems?
- If I put the SimpleText Guide in the Extensions folder, it does not
appear in the Guide menu when SimpleText is open. It must be in the same
folder as SimpleText to show up.
- The first help item I tried in SimpleText, How do I open a document,
doesn't work. It doesn't know that the GetFile dialog is open, and keeps
telling me to open it.
--Alex
---------------------------
>From grinch@ns.moran.com (The Grinch)
Subject: Boot Blocks Again
Date: Wed, 25 Oct 1995 18:22:41 -0400
Organization: Vortex Software
Where can I get the SCSI specs again? I lost the address. (Sorry.) Please
e-mail your replies. Thanx a million.
ÑThe Grinch
+++++++++++++++++++++++++++
>From st955901@pilot.stu.cowan.edu.au (Philip Cummins)
Date: Fri, 27 Oct 1995 12:02:58 +0800
Organization: Edith Cowan University
In article <grinch-2510951822410001@nw19.moran.com>, grinch@ns.moran.com
(The Grinch) wrote:
Hello,
ftp://ftp.symbios.com/pub/standards/io/ <--- Under various folders. Also
ATA = IDE, BTW.
Philip
--
Please exert your creativity to convince yourself there's a signature here.
---------------------------
>From noof@aol.com (Noof)
Subject: Building an FSSpec
Date: 22 Oct 1995 16:25:36 -0400
Organization: America Online, Inc. (1-800-827-6364)
What is the easiest way to build an FSSpec for a file that my application
is going to read when I know that the file will always be in the same
folder as the app that's going to read it and I know the name of the file?
Some how I need to find out the parent directory ID. How do I do that?
Thanks,
David Knuth
+++++++++++++++++++++++++++
>From Francois-Regis.Degott@imag.fr (F. Degott)
Date: 24 Oct 1995 16:26:23 GMT
Organization: LMC-IMAG Grenoble France
In article <46e9c0$m0f@newsbf02.news.aol.com>, noof@aol.com (Noof) wrote:
>What is the easiest way to build an FSSpec for a file that my application
>is going to read when I know that the file will always be in the same
>folder as the app that's going to read it and I know the name of the file?
>
>Some how I need to find out the parent directory ID. How do I do that?
Hi David,
see the Process Manager chapter, in IM vol.6,
specially:
- the GetCurrentProcess() proc.,
- the GetProcessInformation() proc.,
- the ProcessAppSpec field of the ProcessInfoRec structure.
OSErr GetCurrentProcessFSSpec (FSSpec *fspec)
{
OSErr err;
ProcessSerialNumber psn;
ProcessInfoRec pinfo;
err = GetCurrentProcess(&psn);
if (err == NoErr)
{
pinfo.processInfoLength = sizeof(ProcessInfoRec);
pinfo.processName = NULL;
pinfo.processAppSpec = fspec;
err = GetProcessInfo(psn,&pinfo);
}
return(err);
}
in main:
FSSpec AppFSSpec;
…
if (GetCurrentProcessFSSpec(&AppFSSpec) == NoErr)
{
/*do stuff with AppFSSpec*/
}
Hope this helps.
Fr
___________________________________________________________________________
FR Degott (Francois-Regis.Degott@imag.fr)
LogiMath, Lab. LMC-IMAG - Grenoble - France
+++++++++++++++++++++++++++
>From sproul@eos.ap.org (Mark Sproul)
Date: Thu, 26 Oct 1995 11:09:09 -0400
Organization: Associated Press R&D
In article <Francois-Regis.Degott-2410951727150001@harpie.imag.fr>,
Francois-Regis.Degott@imag.fr (F. Degott) wrote:
> In article <46e9c0$m0f@newsbf02.news.aol.com>, noof@aol.com (Noof) wrote:
>
> >What is the easiest way to build an FSSpec for a file that my application
> >is going to read when I know that the file will always be in the same
> >folder as the app that's going to read it and I know the name of the file?
> >
> >Some how I need to find out the parent directory ID. How do I do that?
use 0 for the vRefNum and 0 for the parID in MakeFsSpec, thats all there
is to it.
Mark
---------------------------
>From demos@home.amug.org (Demos)
Subject: Drag And Drop for TextEdit
Date: Mon, 23 Oct 1995 02:59:59 +0100
Organization: AMUG
Hi everyone!
I am writing a better wrap for TextEdit in PowerPlant : LNewTextEdit.
Anyone knows any examples that handle plain Drag and Drop just like in
SimpleText with TextEdit? I think, I saw a sample code on the develop
CD once. But I failed to find it now.
Let me know if you have something.
thanks!
Demos
___________________________________________________________________
Demos <demos@home.amug.org> | IRC: #macdev | http://amug.org/~demos
+++++++++++++++++++++++++++
>From j-norstad@nwu.edu (John Norstad)
Date: Mon, 23 Oct 1995 19:20:23 -0500
Organization: Northwestern University
In article <demos-2310950259590001@chem-25.chem.utah.edu>,
demos@home.amug.org (Demos) wrote:
> Hi everyone!
> I am writing a better wrap for TextEdit in PowerPlant : LNewTextEdit.
> Anyone knows any examples that handle plain Drag and Drop just like in
> SimpleText with TextEdit? I think, I saw a sample code on the develop
> CD once. But I failed to find it now.
>
> Let me know if you have something.
I implemented drag and drop with TextEdit in my NewsWatcher program.
Source code is available at:
<ftp://ftp.acns.nwu.edu/pub/newswatcher/>
In particular, see some of the resuable code in the teutil.c and
dragutil.c modules.
One thing I learned is that text drag and drop really requires that you
also implement intelligent cut and paste. E.g., if you drag a word from
one place in your text to another place, you really need to go through all
that delete extra space character and insert extra space character
nonsense. I did that in NewsWatcher too. It was delicate, and I had to go
back and fix my code several times before I got it right, but I think it's
working pretty well now.
--
John Norstad
Academic Technologies
Northwestern University
j-norstad@nwu.edu
<http://charlotte.acns.nwu.edu/jln/jln.html>
---------------------------
>From nordic@inetnebr.com (Dave)
Subject: Getting file info from file reference number
Date: 17 Oct 1995 22:05:06 GMT
Organization: Nordic Software
Hi All,
Is there a way to get file information ( specifically a file name )
from a file access path reference number, such as the number returned from
OpenResFile?
I am working with someone elses code. At some point a resource file is
getting opened. For the life of me I cannot find the file that is open.
I am getting a bogus dialog and I cannot find what res file it is in. I
have the file reference number however.
There probably is a simple answer that I am overlooking. I can fix the
bug but now my curiosity is peaked....
Thanks
Dave
+++++++++++++++++++++++++++
>From phixus@deltanet.com (Chris De Salvo)
Date: Tue, 17 Oct 1995 21:17:54 -0700
Organization: MacPlay
In article <nordic-1710951704310001@in76.inetnebr.com>,
nordic@inetnebr.com (Dave) wrote:
> Hi All,
> Is there a way to get file information ( specifically a file name )
> from a file access path reference number, such as the number returned from
> OpenResFile?
There sure is. There's a wonderful call known as PBGetFCBInfo(). Pass it
a fileRef and it gives you back all of the info from the file control
block associated with that open file.
Here's an example that should get you the name of the file:
FCBPBRec fileRec;
OSErr theErr;
Str255 fileName;
//• Get information on this open file
fileRec.ioCompletion = nil; //• Not asynch
fileRec.ioFCBIndx = 0; //• Check on all open files
fileRec.ioVRefNum = 0; //• On all volumes
fileRec.ioRefNum = fileRef;
fileRec.ioNamePtr = fileName; //• Name get's filled in here
theErr = PBGetFCBInfo(&fileRec, FALSE);
You'd never believe how happy I was the first time that I discovered this
call. It solved a VERY nasty problem for me. :)
L8R,
Chris
--
+-----------------------------------------------------------------+
| phixus@deltanet.com | Macintosh: Changing the world, |
| Chris De Salvo | one person at a time! |
| Professional Mac Geek | ----------------------------- |
| for MacPlay, Inc. | (I wish they'd hurry up!) |
+-----------------------------------------------------------------+
Any opinions expressed, or implied, are my own! They should not be
considered representative of the opinions or policies of my employer,
MacPlay, a division of Interplay Productions, Inc.
+++++++++++++++++++++++++++
>From grinch@ns.moran.com (The Grinch)
Date: Thu, 19 Oct 1995 18:45:19 -0400
Organization: Vortex Software
In article <nordic-1710951704310001@in76.inetnebr.com>,
nordic@inetnebr.com (Dave) wrote:
> Hi All,
> Is there a way to get file information ( specifically a file name )
> from a file access path reference number?
I think so. (Untested.) Just step right on through the FCB queue, in
through the fcbBTCBPtr fields, until you find your number in the btcRefNum
field of the BTCB. Good luck; you'll probably need it!
ÑThe Grinch B-)
+++++++++++++++++++++++++++
>From jeremyr@dcs.qmw.ac.uk (Jeremy Roussak)
Date: 21 Oct 1995 06:13:51 GMT
Organization: Queen Mary & Westfield College, London, England
In article <grinch-1910951845190001@nw35.moran.com>
grinch@ns.moran.com (The Grinch) writes:
> In article <nordic-1710951704310001@in76.inetnebr.com>,
> nordic@inetnebr.com (Dave) wrote:
>
> > Hi All,
> > Is there a way to get file information ( specifically a file name )
> > from a file access path reference number?
>
> I think so. (Untested.) Just step right on through the FCB queue, in
> through the fcbBTCBPtr fields, until you find your number in the btcRefNum
> field of the BTCB. Good luck; you'll probably need it!
On the other hand, if you use PBGetFCBInfo, you'll get the information
and you'll need a lot less luck.
Jeremy
+++++++++++++++++++++++++++
>From gotow@stclairsw.com (Jon Gotow)
Date: Mon, 23 Oct 1995 23:50:34 -0500
Organization: St. Clair Software
In article <grinch-1910951845190001@nw35.moran.com>, grinch@ns.moran.com
(The Grinch) wrote:
> In article <nordic-1710951704310001@in76.inetnebr.com>,
> nordic@inetnebr.com (Dave) wrote:
>
> > Hi All,
> > Is there a way to get file information ( specifically a file name )
> > from a file access path reference number?
>
> I think so. (Untested.) Just step right on through the FCB queue, in
> through the fcbBTCBPtr fields, until you find your number in the btcRefNum
> field of the BTCB. Good luck; you'll probably need it!
Just use PBGetFCBInfo() - Inside Mac IV, page 179, for those that still
have the old paper copies.
- Jon
________________________________________________________________________
Jon Gotow gotow@stclairsw.com
St. Clair Software http://www.stclairsw.com/stclairsw/
Fax (412)835-4402 ftp://ftp.stclairsw.com/stclairsw/
---------------------------
>From starlabs@aol.com (StarLabs)
Subject: PPC App + 68K module & callbacks (how?)
Date: 23 Oct 1995 05:35:06 -0400
Organization: America Online, Inc. (1-800-827-6364)
Sorry if this seems like a trivial question, but since I'm new to this UPP
business...
I'm planning on writing a fat application that supports plug-in code
modules.
Because of my inherent laziness I would prefer the code modules to be 68K
only.
The problem is with this scenario: assuming I'm running on a PowerMac and
since the PPC version of my application is running, what happens when it
loads and invokes the 68K module and the module makes a callback to the
fat application? In other words, how do I implement this?!? Currently I
have
given the code module a ProcPtr only for callbacks (since it's 68K only).
I have a feeling this won't work [I can't test it on a PowerMac yet].
I know the fat application will do this right thing by calling
CallUniversalProc to invoke the 68K code module (and thereby telling the
Mixed Mode manager of the inherent switch in architectures) but how do I
implement callbacks for the 68K code module? Since it's 68K it only knows
ProcPtrs and can't tell the Mixed Mode manager of the switch from 68K to
PPC. Ack! I'm confused!
I have a bad feeling I'll have to resort to writing safe fat code
modules :-(
--Hiep
+++++++++++++++++++++++++++
>From "Andrew C. Plotkin" <erkyrath+@CMU.EDU>
Date: Mon, 23 Oct 1995 11:47:28 -0400
Organization: Carnegie Mellon, Pittsburgh, PA
starlabs@aol.com (StarLabs) writes:
> I'm planning on writing a fat application that supports plug-in code
> modules.
> Because of my inherent laziness I would prefer the code modules to be 68K
> only.
>
> The problem is with this scenario: assuming I'm running on a PowerMac and
> since the PPC version of my application is running, what happens when it
> loads and invokes the 68K module and the module makes a callback to the
> fat application? In other words, how do I implement this?!? Currently I
> have
> given the code module a ProcPtr only for callbacks (since it's 68K only).
> I have a feeling this won't work [I can't test it on a PowerMac yet].
Sneakily, it will work. You pass in a UPP and tell the 68K code it's a
function pointer. The 68K code calls it (naive fool that it is.)
The 68K emulator begins actually executing the UPP block... which is
legal, because a UPP block always begins with the A-trap which leads
into the Mixed-Mode Manager.
Then the magic takes over. It's all pretty clever, really.
--Z
"And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..."
---------------------------
>From erichsen@pacificnet.net (Erichsen)
Subject: Q: Time Manager vs TickCount for Animation?
Date: Wed, 04 Oct 1995 13:19:34 -0700
Organization: Disorganized
Why do people use the Time Manager instead of TickCount() when doing
animation? It seems like a lot of overhead is involved when using the Time
Manager especially so if the Time Manager isn't native (ie. mode switches)
so what's the real benefit of using it over just checking TickCount() for
when to draw the animation?
+++++++++++++++++++++++++++
>From phixus@deltanet.com (Chris De Salvo)
Date: Thu, 05 Oct 1995 00:45:35 -0700
Organization: MacPlay
In article <erichsen-0410951319340001@pm1-3.pacificnet.net>,
erichsen@pacificnet.net (Erichsen) wrote:
> Why do people use the Time Manager instead of TickCount() when doing
> animation? It seems like a lot of overhead is involved when using the Time
> Manager especially so if the Time Manager isn't native (ie. mode switches)
> so what's the real benefit of using it over just checking TickCount() for
> when to draw the animation?
Well, finer resolution is one thing. TickCount() only has 60th of a
second resolution. If you need something higher than that, then you're
hosed.
The main thing is ease of use. If you use TickCount() you have to
manually check the value to see when it's time to do the next frame. If
you use the Time Manager then your timer task can just set a global
variable saying that it's time to do the next frame. That way, no matter
where you are in your code the flag gets set and you always have
up-to-date info on the state of things.
If you needed to check the time in more than one place then you'd have to
set a global with the future time, and check it all over the place.
Plus, let's say you wanted something like, "Ok, the player stepped on a
boobytrap. In 7.5 seconds, spring the trap". Checking things like that
with TickCount() is a pain in the butt. Especially when the Time Manager
does it accurately, and conveniently, with a callback.
When you have a recurring task, nothing beats the Time Manager. eg. When
I did SimCity CD-ROM, I had a Time Manager task that fired every 10
minutes and triggered an event. It's extremely handy.
L8R
Chris
--
+-----------------------------------------------------------------+
| phixus@deltanet.com | Macintosh: Changing the world, |
| Chris De Salvo | one person at a time! |
| Professional Mac Geek | ----------------------------- |
| for MacPlay, Inc. | (I wish they'd hurry up!) |
+-----------------------------------------------------------------+
Any opinions expressed, or implied, are my own! They should not be
considered representative of the opinions or policies of my employer,
MacPlay, a division of Interplay Productions, Inc.
+++++++++++++++++++++++++++
>From jbruni@primenet.com (Joseph Bruni)
Date: Wed, 04 Oct 1995 23:03:44 -0700
Organization: Primenet
In article <erichsen-0410951319340001@pm1-3.pacificnet.net>,
erichsen@pacificnet.net (Erichsen) wrote:
> Why do people use the Time Manager instead of TickCount() when doing
> animation? It seems like a lot of overhead is involved when using the Time
> Manager especially so if the Time Manager isn't native (ie. mode switches)
> so what's the real benefit of using it over just checking TickCount() for
> when to draw the animation?
TickCount() is updated 60 times a second by a VBL task. But it is very
unreliable (it sometimes misses a beat).
If your animation needs to be synchronized to video, you need to use
something tied to that video. SlotVBL tasks replaced ordinary VBL tasks,
but I think Time Manager tasks replaced those.
+++++++++++++++++++++++++++
>From kluev@macsimum.gamma.ru (Kluev)
Date: Thu, 5 Oct 95 21:40:51 +0300
Organization: (none)
In article <jbruni-0410952303440001@ip237.phx.primenet.com>,
jbruni@primenet.com (Joseph Bruni) wrote:
>In article <erichsen-0410951319340001@pm1-3.pacificnet.net>,
>erichsen@pacificnet.net (Erichsen) wrote:
>
>> Why do people use the Time Manager instead of TickCount() when doing
>> animation? It seems like a lot of overhead is involved when using
the Time
>> Manager especially so if the Time Manager isn't native (ie. mode
switches)
>> so what's the real benefit of using it over just checking
TickCount() for
>> when to draw the animation?
>
>TickCount() is updated 60 times a second by a VBL task. But it is very
>unreliable (it sometimes misses a beat).
AFAICT, TickCount is accurate (i.e. it is updated every tick). What is
not accurate is firing of user VBL tasks. The only source of inaccuracy
of Ticks is disabling interrupts for a long time, and the fact that VBL
mechanizm gets executed after interrupt occurred (deferred time). But
in any case you'll not get your global flag updated until interrupt
cycle completed.
>If your animation needs to be synchronized to video, you need to use
>something tied to that video. SlotVBL tasks replaced ordinary VBL
tasks,
>but I think Time Manager tasks replaced those.
The only way to sync. with video nowadays is SlotVBL task.
- --------------------------------------------------------------
Michael Kluev kluev@macsimum.gamma.ru
Macintosh Programmer Physics Grad, MSU
MACsimum Ltd. Moscow, Russia
- --------------------------------------------------------------
+++++++++++++++++++++++++++
>From scu60@earthlink.net (David Padilla)
Date: Tue, 10 Oct 1995 00:59:11 -0800
Organization: Earthlink Network, Inc.
In article <phixus-0510950045350001@ana0012.deltanet.com>,
phixus@deltanet.com (Chris De Salvo) wrote:
> In article <erichsen-0410951319340001@pm1-3.pacificnet.net>,
> erichsen@pacificnet.net (Erichsen) wrote:
>
> > Why do people use the Time Manager instead of TickCount() when doing
> > animation? It seems like a lot of overhead is involved when using the Time
> > Manager especially so if the Time Manager isn't native (ie. mode switches)
> > so what's the real benefit of using it over just checking TickCount() for
> > when to draw the animation?
>
> Well, finer resolution is one thing. TickCount() only has 60th of a
> second resolution. If you need something higher than that, then you're
> hosed.
>
> The main thing is ease of use. If you use TickCount() you have to
> manually check the value to see when it's time to do the next frame. If
> you use the Time Manager then your timer task can just set a global
> variable saying that it's time to do the next frame. That way, no matter
> where you are in your code the flag gets set and you always have
> up-to-date info on the state of things.
>
How do you use the Time Manager and a global to control an animation
sequence? I have never seen this done. Could someone provide a simple
example or direct me to a to one? I am new to this animaton stuff, but am
becomming ok (if I do say so myself), so the more basic the example the
better. Currently, I have been using a simple while and tickcount method
to control things.
All advice appreciated.
David
+++++++++++++++++++++++++++
>From erichsen@pacificnet.net (Erichsen)
Date: Wed, 11 Oct 1995 18:52:35 -0700
Organization: Disorganized
In article <scu60-1010950059120001@204.250.136.234>, scu60@earthlink.net
(David Padilla) wrote:
>How do you use the Time Manager and a global to control an animation
>sequence? I have never seen this done. Could someone provide a simple
>example or direct me to a to one? I am new to this animaton stuff, but am
>becomming ok (if I do say so myself), so the more basic the example the
>better. Currently, I have been using a simple while and tickcount method
>to control things.
You just setup a Time Manager Task to fire off at a certain interval and
from the task's completion routine, you set the global.
If you want to see actual code, check out SpriteWorld, it does this and
it's pretty straightforward.
+++++++++++++++++++++++++++
>From erichsen@pacificnet.net (Erichsen)
Date: Sun, 15 Oct 1995 14:10:53 -0700
Organization: Disorganized
In article <660996062.16983248@gammabbs.uucp.netcom.com>,
David_M._Padilla@gammabbs.uucp.netcom.com wrote:
>Could you point me to the location and excat file name of SpriteWorld, I
>checked AOL and there were a number of Sprite type file archives. Thanks much
>for the direction.
I'm not on AOL but, it's on Info-Mac
<ftp://sumex-aim.stanford.edu/info-mac/> in the dev/src area.
+++++++++++++++++++++++++++
>From David_M._Padilla@gammabbs.uucp.netcom.com (David M. Padilla)
Date: 14 Oct 1995 05:14:06 GMT
Organization: Gamma Quadrant BBS
>>> You just setup a Time Manager Task to fire off at a certain
>>> interval and from the task's completion routine, you set the
>>> global.
>>>
>>> If you want to see actual code, check out SpriteWorld, it does this
>>> and it's pretty straightforward.
Could you point me to the location and excat file name of SpriteWorld, I
checked AOL and there were a number of Sprite type file archives. Thanks much
for the direction.
Dave
- ---------------------------------
The Gamma Quadrant - FirstClass BBS
Huntington Beach, CA (714) 840-7497
- ---------------------------------
+++++++++++++++++++++++++++
>From peter@stairways.com.au (Peter N Lewis)
Date: Fri, 27 Oct 1995 13:42:26 +0800
Organization: Stairways Software
In article <erichsen-0410951319340001@pm1-3.pacificnet.net>,
erichsen@pacificnet.net (Erichsen) wrote:
>Why do people use the Time Manager instead of TickCount() when doing
>animation? It seems like a lot of overhead is involved when using the Time
>Manager especially so if the Time Manager isn't native (ie. mode switches)
>so what's the real benefit of using it over just checking TickCount() for
>when to draw the animation?
If you don't want a callback, and just want more accuracy/resulution than
TickCount, you can use Microseconds.
Microseconds(VAR microTickCount:UnsignedWide);
I think it came in in System 7, so it should always be available unless
you want to support System 6. It returns the number of microseconds since
boot in a 64-bit wide number. It's not accurate to microseconds
obviously, I think it's accurate to about 20 microseconds.
Enjoy,
Peter.
--
"there is no significant correlation to violence on TV and agression in
daily life" - NHR Broadcasting Culture Research Institute in Tokyo.
---------------------------
>From trygve@netcom.com (Trygve Isaacson)
Subject: Q: system heap expansion at init time
Date: Thu, 26 Oct 1995 05:06:37 GMT
Organization: Freak Accident Music
I have an INIT that looks for certain files of mine, and for each file
found, it loads a code segment from the file, and also grows a system heap
handle that contains info about each found file. It's basically an API
that's doing the dynamic linking to the plug-ins at INIT time.
What I'm seeing is "out of memory" (-108) or NULL result when allocating
space for the code or growing the handle, once I get up to around the 7th
file or so. The loaded code is 10K or less per file, and the handle growth
is under 1K per file.
Now, I understood that the system heap under 7.0 and later (I'm running
7.5.1 on a 7100/66) grew automatically, making the 'sysz' resource
obsolete (though I've seen behavior to the contrary for 'sysz'), and to
some degree making INIT time system heap allocations (of small amounts
like this at least) pretty certain to succeed. Are there precautions I can
take, such as allocating the memory in a particular way, to make the
allocations succeed?
Thanks in advance,
Trygve Isaacson
trygve@kagi.com
+++++++++++++++++++++++++++
>From wysocki@netcom.com (Chris Wysocki)
Date: Thu, 26 Oct 1995 07:52:05 GMT
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
In article <trygve-2510952207170001@10.0.2.15>,
Trygve Isaacson <trygve@netcom.com> wrote:
>Now, I understood that the system heap under 7.0 and later (I'm running
>7.5.1 on a 7100/66) grew automatically, making the 'sysz' resource
>obsolete (though I've seen behavior to the contrary for 'sysz'), and to
>some degree making INIT time system heap allocations (of small amounts
>like this at least) pretty certain to succeed. Are there precautions I can
>take, such as allocating the memory in a particular way, to make the
>allocations succeed?
While the system heap can and does grow and shrink dynamically under
System 7.x, an INIT still needs to include a 'sysz' resource to ensure
that the System can reserve enough memory for it during startup. The
system automatically reserves a certain minimal amount of system heap
space for every INIT (16K or so, I can't recall the exact amount), but
to be safe any INIT that allocates memory in the system heap should
include a 'sysz' resource to tell the system how much memory it might
expect to require.
Chris.
+++++++++++++++++++++++++++
>From larson@base.cs.ucla.edu (Christopher Larson)
Date: 26 Oct 1995 16:17:28 GMT
Organization: UCLA, Computer Science Department
In article <trygve-2510952207170001@10.0.2.15> trygve@netcom.com (Trygve Isaacson) writes:
>Now, I understood that the system heap under 7.0 and later (I'm running
>7.5.1 on a 7100/66) grew automatically, making the 'sysz' resource
>obsolete (though I've seen behavior to the contrary for 'sysz'), and to
>some degree making INIT time system heap allocations (of small amounts
>like this at least) pretty certain to succeed. Are there precautions I can
>take, such as allocating the memory in a particular way, to make the
>allocations succeed?
You do still need a 'sysz' resource in System 7. Try using one and get
back to us if you still have problems.
--Chris
_______________________________________________________________________________
Chris Larson -- Amateur Macintosh Geek, CoBase Research Assistant
L.A. Institute of Slowly and Painfully Working Out the Surprisingly Obvious
- -------------------------------------+---------------------------------------
(Insert Disclaimer Here) | Who's the man ridin' in the sun?
UCLA Bruins--1995 NCAA Men's Basketball| Who's the man with the itchy gun?
National Champions (yea!) | Who's the man who kills for fun?
Internet: larson@kingston.cs.ucla.edu | Psycho Dad, Psycho Dad, PSYCHO DAD!
---------------------------
>From greg@ohs.uwo.ca (Greg Chapman)
Subject: [Q] To form this FSSpec...
Date: Mon, 23 Oct 1995 14:23:01 -0500
Organization: U. of Western Ontario, OHS
How would one go about forming an FSSpec for a file
knowing *only* the full path name?
For instance, I know the file is named...
Macintosh HD:pub:msds:mercury oxide
... and that's *all* I know about the file... and the solution has eluded
me. Any ideas on how to form the FSSpec?
--
Greg Chapman - Mac Programmer/Developer
Systems Manager - U. of Western Ontario OHS
London, Ontario, Canada
email: greg@ohs.uwo.ca
- -
"... cleans teeth, while you do dishes!"
+++++++++++++++++++++++++++
>From rickc@i-link.net (Richard Cardona)
Date: Mon, 23 Oct 1995 16:19:26 -0500
Organization: TradeWave Corporation (formerly EINet)
In article <greg-2310951423010001@mail.ohs.uwo.ca>, greg@ohs.uwo.ca (Greg
Chapman) wrote:
stance, I know the file is named...
>
> Macintosh HD:pub:msds:mercury oxide
>
> ... and that's *all* I know about the file... and the solution has eluded
> me. Any ideas on how to form the FSSpec?
>
Well there's a little problem. The MacOS allows volumes with the same
name to be mounted simulateneously. So this "path" is not necessary
unique.
In the simple case that it is (like 90%?) a Mac that has only one internal
drive (remember I could name a floppy "Macintosh HD" too), then you call
FSMakeFSSpec with vRefnum = 0, dirID = 0 and filename as the full path.
Rick
+++++++++++++++++++++++++++
>From sample@esltd.com (Don Sample)
Date: Tue, 24 Oct 1995 13:48:44 -0400
Organization: Enterprise Solutions Ltd
In article <greg-2310951423010001@mail.ohs.uwo.ca>, greg@ohs.uwo.ca (Greg
Chapman) wrote:
> How would one go about forming an FSSpec for a file
> knowing *only* the full path name?
>
> For instance, I know the file is named...
>
> Macintosh HD:pub:msds:mercury oxide
>
> ... and that's *all* I know about the file... and the solution has eluded
> me. Any ideas on how to form the FSSpec?
>
Use FSMakeFSSpec. If you pass it a full path name in the filename
parameter it will ignore the vRefnum and dirID parameters and use the
path.
Str255 pathName = "\pMacintosh HD:pub:msds:mercury oxide";
FSSpec fsSpec;
...
err = FSMakeFSSpec(0, 0, pathName, &fsSpec);
+++++++++++++++++++++++++++
>From Mark_Weinstein@msn.com (Mark Weinstein)
Date: 25 Oct 95 06:39:59 -0700
Organization: TheMicrosoftNetwork(msn.com)
>How would one go about forming an FSSpec for a file
>knowing *only* the full path name?
>
>For instance, I know the file is named...
>
>Macintosh HD:pub:msds:mercury oxide
>
>... and that's *all* I know about the file... and the solution has
>eluded me. Any ideas on how to form the FSSpec?
Yea, but take heed of what the other guy said; if there are TWO disks
mounted on your Mac's desktop with the name "Macintosh HD", then you
may wind up with unpredictable results, as you may be unable to tell
which volume was chosen. Usually the first volume that was mounted
on your Macintosh desktop with that name (the one with the "highest
volume reference number") was the one chosen. But here's the way you
can do it.
#include <string.h>
short get_fsspec_from_full_path( StringPtr name, FSSpec *fss )
{
short err;
HParamBlockRec rec;
memset( ( void * )&rec, 0, sizeof( rec ) );
/* I usually zero the entire parameter block out for safety */
/* But you don't have to clear the whole thing out.. */
/* ioVRefNum, ioDirID, ioCompletion, and a few other fields */
/* should be cleared. */
pb.ioNamePtr = name;
pb.ioMisc = ( Ptr )fss;
return( PBMakeFSSpecSync( ( void * )&pb ) );
}
That's it. Just call that like this:
void main ( void )
{
short err;
FSSpec mySpec;
err = get_fsspec_from_full_path( "\pMacintosh HD:pub:msds:mercury
oxide", &mySpec );
if ( err != noErr ) {
/* Something happened, probably file/path not found */
return;
}
/* You have a valid FSSpec.. */
}
Later. MRW.
+++++++++++++++++++++++++++
>From sample@esltd.com (Don Sample)
Date: Tue, 24 Oct 1995 13:48:44 -0400
Organization: Enterprise Solutions Ltd
In article <greg-2310951423010001@mail.ohs.uwo.ca>, greg@ohs.uwo.ca (Greg
Chapman) wrote:
> How would one go about forming an FSSpec for a file
> knowing *only* the full path name?
>
> For instance, I know the file is named...
>
> Macintosh HD:pub:msds:mercury oxide
>
> ... and that's *all* I know about the file... and the solution has eluded
> me. Any ideas on how to form the FSSpec?
>
Use FSMakeFSSpec. If you pass it a full path name in the filename
parameter it will ignore the vRefnum and dirID parameters and use the
path.
Str255 pathName = "\pMacintosh HD:pub:msds:mercury oxide";
FSSpec fsSpec;
...
err = FSMakeFSSpec(0, 0, pathName, &fsSpec);
---------------------------
End of C.S.M.P. Digest
**********************